const App = {
  mixins: [Query], //配置文件，路径/utils/mixins.js
  data() {
    return {
      statistics: {
        A类人员: { total: 0 },
        B类人员: { total: 0 },
        C类人员: { total: 0 },
        D类人员: { total: 0 },
      },
      teeed: "",
      party_fees: {
        Party_Fee_SerialNumber: "", //党费缴纳流水号
        Party_Member_SerialNumber: "", //党员流水号
        Party_Organization_SerialNumber: "", //所属党组织编号
        Fee_Date: "", //党费日期
        Fee_Amount: "", //党费金额
      },
      totalMembers: 111, //总人数
      fullMembers: 11, //正式党员
      probationaryMembers: 1, //预备党员
      input: "", //输入框
      value2: getYMDate(),
      options: [],
      treeData: [], //树的数据
      originalTreeData: [], //原始树的数据
      originalTableData: [], // 原始表格的数据
      columns: [], //表格的列
      loading: false, //表数据的懒加载
      showDialog: false, //设置字段弹窗
      checkedFields: [], //选中的字段
      isDataReady: false,
      Tabletdata: [], //表格的数据
      fields: [], //字段列表
      // showaddDialog: false, //添加字段弹窗
      value: "",
      page: {
        value1: "",
        value2: "",
        value3: "",
        PageNumber: 1, //页码
        RowAmount: 10,
        Condition: window.btoa(unescape(encodeURIComponent("%%,%%,%%"))),
        ExtensionCondition: "",
      },

      calendar: false,
      Party_Organization_SerialNumber: "",
      organization: [],
    };
  },
  mounted() {
    this.Treedata();
    this.ctj();
  },
  methods: {
    ctj() {
      const _this = this;
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/population/keyPersonStatistics`,
        type: "GET",
        data: {
          Town_SerialNumber: "", //请求参数
        },
        success: function (data) {
          for (const key in _this.statistics) {
            if (data[key] !== undefined) {
              _this.statistics[key].total = data[key];
            }
          }
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        method: "post",
        data: {
            Data: 'personal_tags',
            Condition: `Row_Status='0'`,
        },
        success: (res) => {
          this.options = res
        },
        complete: (XMLHttpRequest) => {
            requestPretreatment(XMLHttpRequest)
        },
    });
    },
    //树的数据
    Treedata() {
      const _this = this;
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/clientOperation/getDistrictTree`,
        type: "GET",
        data: {
          DistrictCode: "232723", //请求参数
        },
        success: function (data) {
          console.log(data);
          _this.treeData = data;
          // 使用深拷贝赋值 originalTreeData
          // _this.originalTreeData = JSON.parse(JSON.stringify(data));
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    personalAdd() {
      window.location.href = "./party_feesAdd.html?action=Modify";
    },
    handleEdit(row) {
      let { primary_key } = JSON.parse(
        document.getElementById("table").getAttribute("data-options")
      );
      window.location.href =
        "./party_feesAdd.html?action=Modify&nodeKey=" + row[primary_key];
    },
    check() {
      this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%" + this.page.value1 + "%,%" + this.page.value2 + "%")));
      if (this.page.value3) {
        console.log(this.page.value3);
        this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent("AND personal_mapping_tags.Personal_Tag_SerialNumber = '" + this.page.value3 +"'")));
      } else {
        this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent("")));
      }
      this.postgetList(this.page);
    },
    handleNodeClick(data) {
      this.page.Condition = window.btoa(
        unescape(
          encodeURIComponent(
            "%" +
            data.ProvinceNumber +
            "%,%" +
            this.page.value1 +
            "%,%" +
            this.page.value2 +
            "%"
          )
        )
      );
      this.postgetList(this.page);
    },
    handlebj(row) {
      this.$confirm('是否' + (row.Focus == '0' ? '重点关注' : '取消关注') + '该人员', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        let { TableName, primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
        $.ajax({
          headers: requestHeaders(),
          url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
          method: "post",
          data: {
            Data: TableName,
            Condition: primary_key + "='" + row[primary_key] + "'"
          },
          success: (res) => {
            if (res.length == 1) {
              res[0].Focus = (row.Focus == '0' ? '1' : '0');
              let lJSONObject_DataSet = new Object();
              let lJSONObject_Table = new Object();
              lJSONObject_Table[TableName] = res;
              lJSONObject_DataSet['Modify'] = lJSONObject_Table;
              let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
              if (!lJSONObject_DataSet['Add']) {
                lJSONObject_DataSet['Add'] = new Object();
              }
              lJSONObject_DataSet['Add']['base_operation_log'] = [{
                Operation_Type: '0',
                Operation_Path: this.relativePath,
                Operation_Main,
                Operation_Interface: "generalSave",
                Operation_IP: getIpAddress()
              }]
              $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalSave`,
                method: "post",
                data: {
                  Data: JSON.stringify(lJSONObject_DataSet),
                },
                success: (res) => {
                  if (res.Status == 'success') {
                    this.postgetList(this.page);
                  } else {
                    this.$message({
                      type: 'error',
                      message: '操作失败'
                    });
                  }
                },
                complete: (XMLHttpRequest) => {

                  requestPretreatment(XMLHttpRequest);
                }
              });
            } else {
              this.$message({
                type: 'error',
                message: '操作失败'
              });
            }

          }, complete: (XMLHttpRequest) => {

            requestPretreatment(XMLHttpRequest);
          }
        });
      }).catch(() => { });
    }
  },
};
const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.component("yl-monthly-calendar", ylMonthlyCalendar);
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
